/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.hellodoctor.slayer.model.impl;

import com.hellodoctor.slayer.model.Profile;
import com.hellodoctor.slayer.model.ProfileModel;
import com.hellodoctor.slayer.model.ProfileSoap;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The base model implementation for the Profile service. Represents a row in the &quot;hd_Profile&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.hellodoctor.slayer.model.ProfileModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ProfileImpl}.
 * </p>
 *
 * @author Shahbaj
 * @see ProfileImpl
 * @see com.hellodoctor.slayer.model.Profile
 * @see com.hellodoctor.slayer.model.ProfileModel
 * @generated
 */
@JSON(strict = true)
public class ProfileModelImpl extends BaseModelImpl<Profile>
	implements ProfileModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a profile model instance should use the {@link com.hellodoctor.slayer.model.Profile} interface instead.
	 */
	public static final String TABLE_NAME = "hd_Profile";
	public static final Object[][] TABLE_COLUMNS = {
			{ "profileId", Types.BIGINT },
			{ "userId", Types.BIGINT },
			{ "isDoctor", Types.BOOLEAN },
			{ "speciality", Types.INTEGER },
			{ "qualification", Types.INTEGER },
			{ "practicingSince", Types.INTEGER },
			{ "createDate", Types.TIMESTAMP },
			{ "modifiedDate", Types.TIMESTAMP }
		};
	public static final String TABLE_SQL_CREATE = "create table hd_Profile (profileId LONG not null primary key,userId LONG,isDoctor BOOLEAN,speciality INTEGER,qualification INTEGER,practicingSince INTEGER,createDate DATE null,modifiedDate DATE null)";
	public static final String TABLE_SQL_DROP = "drop table hd_Profile";
	public static final String ORDER_BY_JPQL = " ORDER BY profile.profileId ASC";
	public static final String ORDER_BY_SQL = " ORDER BY hd_Profile.profileId ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.hellodoctor.slayer.model.Profile"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.hellodoctor.slayer.model.Profile"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.hellodoctor.slayer.model.Profile"),
			true);
	public static long USERID_COLUMN_BITMASK = 1L;
	public static long PROFILEID_COLUMN_BITMASK = 2L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static Profile toModel(ProfileSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		Profile model = new ProfileImpl();

		model.setProfileId(soapModel.getProfileId());
		model.setUserId(soapModel.getUserId());
		model.setIsDoctor(soapModel.getIsDoctor());
		model.setSpeciality(soapModel.getSpeciality());
		model.setQualification(soapModel.getQualification());
		model.setPracticingSince(soapModel.getPracticingSince());
		model.setCreateDate(soapModel.getCreateDate());
		model.setModifiedDate(soapModel.getModifiedDate());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<Profile> toModels(ProfileSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<Profile> models = new ArrayList<Profile>(soapModels.length);

		for (ProfileSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.hellodoctor.slayer.model.Profile"));

	public ProfileModelImpl() {
	}

	@Override
	public long getPrimaryKey() {
		return _profileId;
	}

	@Override
	public void setPrimaryKey(long primaryKey) {
		setProfileId(primaryKey);
	}

	@Override
	public Serializable getPrimaryKeyObj() {
		return _profileId;
	}

	@Override
	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Class<?> getModelClass() {
		return Profile.class;
	}

	@Override
	public String getModelClassName() {
		return Profile.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("profileId", getProfileId());
		attributes.put("userId", getUserId());
		attributes.put("isDoctor", getIsDoctor());
		attributes.put("speciality", getSpeciality());
		attributes.put("qualification", getQualification());
		attributes.put("practicingSince", getPracticingSince());
		attributes.put("createDate", getCreateDate());
		attributes.put("modifiedDate", getModifiedDate());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long profileId = (Long)attributes.get("profileId");

		if (profileId != null) {
			setProfileId(profileId);
		}

		Long userId = (Long)attributes.get("userId");

		if (userId != null) {
			setUserId(userId);
		}

		Boolean isDoctor = (Boolean)attributes.get("isDoctor");

		if (isDoctor != null) {
			setIsDoctor(isDoctor);
		}

		Integer speciality = (Integer)attributes.get("speciality");

		if (speciality != null) {
			setSpeciality(speciality);
		}

		Integer qualification = (Integer)attributes.get("qualification");

		if (qualification != null) {
			setQualification(qualification);
		}

		Integer practicingSince = (Integer)attributes.get("practicingSince");

		if (practicingSince != null) {
			setPracticingSince(practicingSince);
		}

		Date createDate = (Date)attributes.get("createDate");

		if (createDate != null) {
			setCreateDate(createDate);
		}

		Date modifiedDate = (Date)attributes.get("modifiedDate");

		if (modifiedDate != null) {
			setModifiedDate(modifiedDate);
		}
	}

	@JSON
	@Override
	public long getProfileId() {
		return _profileId;
	}

	@Override
	public void setProfileId(long profileId) {
		_profileId = profileId;
	}

	@JSON
	@Override
	public long getUserId() {
		return _userId;
	}

	@Override
	public void setUserId(long userId) {
		_columnBitmask |= USERID_COLUMN_BITMASK;

		if (!_setOriginalUserId) {
			_setOriginalUserId = true;

			_originalUserId = _userId;
		}

		_userId = userId;
	}

	@Override
	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	@Override
	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public long getOriginalUserId() {
		return _originalUserId;
	}

	@JSON
	@Override
	public boolean getIsDoctor() {
		return _isDoctor;
	}

	@Override
	public boolean isIsDoctor() {
		return _isDoctor;
	}

	@Override
	public void setIsDoctor(boolean isDoctor) {
		_isDoctor = isDoctor;
	}

	@JSON
	@Override
	public int getSpeciality() {
		return _speciality;
	}

	@Override
	public void setSpeciality(int speciality) {
		_speciality = speciality;
	}

	@JSON
	@Override
	public int getQualification() {
		return _qualification;
	}

	@Override
	public void setQualification(int qualification) {
		_qualification = qualification;
	}

	@JSON
	@Override
	public int getPracticingSince() {
		return _practicingSince;
	}

	@Override
	public void setPracticingSince(int practicingSince) {
		_practicingSince = practicingSince;
	}

	@JSON
	@Override
	public Date getCreateDate() {
		return _createDate;
	}

	@Override
	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	@JSON
	@Override
	public Date getModifiedDate() {
		return _modifiedDate;
	}

	@Override
	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			Profile.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public Profile toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (Profile)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	@Override
	public Object clone() {
		ProfileImpl profileImpl = new ProfileImpl();

		profileImpl.setProfileId(getProfileId());
		profileImpl.setUserId(getUserId());
		profileImpl.setIsDoctor(getIsDoctor());
		profileImpl.setSpeciality(getSpeciality());
		profileImpl.setQualification(getQualification());
		profileImpl.setPracticingSince(getPracticingSince());
		profileImpl.setCreateDate(getCreateDate());
		profileImpl.setModifiedDate(getModifiedDate());

		profileImpl.resetOriginalValues();

		return profileImpl;
	}

	@Override
	public int compareTo(Profile profile) {
		long primaryKey = profile.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof Profile)) {
			return false;
		}

		Profile profile = (Profile)obj;

		long primaryKey = profile.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		ProfileModelImpl profileModelImpl = this;

		profileModelImpl._originalUserId = profileModelImpl._userId;

		profileModelImpl._setOriginalUserId = false;

		profileModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<Profile> toCacheModel() {
		ProfileCacheModel profileCacheModel = new ProfileCacheModel();

		profileCacheModel.profileId = getProfileId();

		profileCacheModel.userId = getUserId();

		profileCacheModel.isDoctor = getIsDoctor();

		profileCacheModel.speciality = getSpeciality();

		profileCacheModel.qualification = getQualification();

		profileCacheModel.practicingSince = getPracticingSince();

		Date createDate = getCreateDate();

		if (createDate != null) {
			profileCacheModel.createDate = createDate.getTime();
		}
		else {
			profileCacheModel.createDate = Long.MIN_VALUE;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			profileCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			profileCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		return profileCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(17);

		sb.append("{profileId=");
		sb.append(getProfileId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", isDoctor=");
		sb.append(getIsDoctor());
		sb.append(", speciality=");
		sb.append(getSpeciality());
		sb.append(", qualification=");
		sb.append(getQualification());
		sb.append(", practicingSince=");
		sb.append(getPracticingSince());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append("}");

		return sb.toString();
	}

	@Override
	public String toXmlString() {
		StringBundler sb = new StringBundler(28);

		sb.append("<model><model-name>");
		sb.append("com.hellodoctor.slayer.model.Profile");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>profileId</column-name><column-value><![CDATA[");
		sb.append(getProfileId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>isDoctor</column-name><column-value><![CDATA[");
		sb.append(getIsDoctor());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>speciality</column-name><column-value><![CDATA[");
		sb.append(getSpeciality());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>qualification</column-name><column-value><![CDATA[");
		sb.append(getQualification());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>practicingSince</column-name><column-value><![CDATA[");
		sb.append(getPracticingSince());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = Profile.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			Profile.class
		};
	private long _profileId;
	private long _userId;
	private String _userUuid;
	private long _originalUserId;
	private boolean _setOriginalUserId;
	private boolean _isDoctor;
	private int _speciality;
	private int _qualification;
	private int _practicingSince;
	private Date _createDate;
	private Date _modifiedDate;
	private long _columnBitmask;
	private Profile _escapedModel;
}